package com.ztjava.upload.controller;

import com.jfinal.aop.Duang;
import com.ztjava.core.Constant;
import com.ztjava.core.annotation.ControllerClass;
import com.ztjava.core.client.PortalClient;
import com.ztjava.ext.auth.annotation.UserController;
import com.ztjava.ext.auth.annotation.UserMethod;
import com.ztjava.ext.auth.bean.AuthSession;
import com.ztjava.upload.service.UploadService;

@ControllerClass(client=PortalClient.class,path="/upload")
@UserController(portal=Constant.P_PORTAL)
public class UploadPortalController extends UploadBaseController {
	private static UploadService uploadService = Duang.duang(UploadService.class);

	@UserMethod
	public void addFiles(){
		keepPara();
		AuthSession authSession = getAttr(Constant.AUTHSESSION);
		String upload_token = getPara("upload_token");
		if(upload_token==null){
			upload_token = uploadService.makeUploadToken(authSession.getId()
					, getPara("plugin").toUpperCase()
					, getPara("component").toUpperCase()
					, getPara("model").toUpperCase(),getParaToInt("object_id"));
		}
		setAttr("upload_token", upload_token);
		render("addFiles.html");
	}
}
